// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Graph
{
	public sealed class GraphExploreRequestParameters : RequestParameters<GraphExploreRequestParameters>
	{
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q<Elastic.Clients.Elasticsearch.Routing?>("routing"); set => Q("routing", value); }

		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }
	}

	public sealed partial class GraphExploreRequest : PlainRequestBase<GraphExploreRequestParameters>
	{
		public GraphExploreRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => r.Required("index", indices))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.GraphExplore;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q<Elastic.Clients.Elasticsearch.Routing?>("routing"); set => Q("routing", value); }

		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

		[JsonInclude]
		[JsonPropertyName("connections")]
		public Elastic.Clients.Elasticsearch.Graph.Hop? Connections { get; set; }

		[JsonInclude]
		[JsonPropertyName("controls")]
		public Elastic.Clients.Elasticsearch.Graph.ExploreControls? Controls { get; set; }

		[JsonInclude]
		[JsonPropertyName("query")]
		public Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? Query { get; set; }

		[JsonInclude]
		[JsonPropertyName("vertices")]
		public IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexDefinition>? Vertices { get; set; }
	}

	public sealed partial class GraphExploreRequestDescriptor<TDocument> : RequestDescriptorBase<GraphExploreRequestDescriptor<TDocument>, GraphExploreRequestParameters>
	{
		internal GraphExploreRequestDescriptor(Action<GraphExploreRequestDescriptor<TDocument>> configure) => configure.Invoke(this);
		public GraphExploreRequestDescriptor(Elastic.Clients.Elasticsearch.Indices indices) : base(r => r.Required("index", indices))
		{
		}

		internal GraphExploreRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.GraphExplore;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public GraphExploreRequestDescriptor<TDocument> Routing(Elastic.Clients.Elasticsearch.Routing? routing) => Qs("routing", routing);
		public GraphExploreRequestDescriptor<TDocument> Timeout(Elastic.Clients.Elasticsearch.Duration? timeout) => Qs("timeout", timeout);
		public GraphExploreRequestDescriptor<TDocument> Indices(Elastic.Clients.Elasticsearch.Indices indices)
		{
			RouteValues.Required("index", indices);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.Graph.Hop? ConnectionsValue { get; set; }

		private HopDescriptor<TDocument> ConnectionsDescriptor { get; set; }

		private Action<HopDescriptor<TDocument>> ConnectionsDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Graph.ExploreControls? ControlsValue { get; set; }

		private ExploreControlsDescriptor<TDocument> ControlsDescriptor { get; set; }

		private Action<ExploreControlsDescriptor<TDocument>> ControlsDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? QueryValue { get; set; }

		private QueryDsl.QueryContainerDescriptor<TDocument> QueryDescriptor { get; set; }

		private Action<QueryDsl.QueryContainerDescriptor<TDocument>> QueryDescriptorAction { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexDefinition>? VerticesValue { get; set; }

		private VertexDefinitionDescriptor<TDocument> VerticesDescriptor { get; set; }

		private Action<VertexDefinitionDescriptor<TDocument>> VerticesDescriptorAction { get; set; }

		private Action<VertexDefinitionDescriptor<TDocument>>[] VerticesDescriptorActions { get; set; }

		public GraphExploreRequestDescriptor<TDocument> Connections(Elastic.Clients.Elasticsearch.Graph.Hop? connections)
		{
			ConnectionsDescriptor = null;
			ConnectionsDescriptorAction = null;
			ConnectionsValue = connections;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Connections(HopDescriptor<TDocument> descriptor)
		{
			ConnectionsValue = null;
			ConnectionsDescriptorAction = null;
			ConnectionsDescriptor = descriptor;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Connections(Action<HopDescriptor<TDocument>> configure)
		{
			ConnectionsValue = null;
			ConnectionsDescriptor = null;
			ConnectionsDescriptorAction = configure;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Controls(Elastic.Clients.Elasticsearch.Graph.ExploreControls? controls)
		{
			ControlsDescriptor = null;
			ControlsDescriptorAction = null;
			ControlsValue = controls;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Controls(ExploreControlsDescriptor<TDocument> descriptor)
		{
			ControlsValue = null;
			ControlsDescriptorAction = null;
			ControlsDescriptor = descriptor;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Controls(Action<ExploreControlsDescriptor<TDocument>> configure)
		{
			ControlsValue = null;
			ControlsDescriptor = null;
			ControlsDescriptorAction = configure;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Query(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? query)
		{
			QueryDescriptor = null;
			QueryDescriptorAction = null;
			QueryValue = query;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Query(QueryDsl.QueryContainerDescriptor<TDocument> descriptor)
		{
			QueryValue = null;
			QueryDescriptorAction = null;
			QueryDescriptor = descriptor;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Query(Action<QueryDsl.QueryContainerDescriptor<TDocument>> configure)
		{
			QueryValue = null;
			QueryDescriptor = null;
			QueryDescriptorAction = configure;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Vertices(IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexDefinition>? vertices)
		{
			VerticesDescriptor = null;
			VerticesDescriptorAction = null;
			VerticesDescriptorActions = null;
			VerticesValue = vertices;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Vertices(VertexDefinitionDescriptor<TDocument> descriptor)
		{
			VerticesValue = null;
			VerticesDescriptorAction = null;
			VerticesDescriptorActions = null;
			VerticesDescriptor = descriptor;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Vertices(Action<VertexDefinitionDescriptor<TDocument>> configure)
		{
			VerticesValue = null;
			VerticesDescriptor = null;
			VerticesDescriptorActions = null;
			VerticesDescriptorAction = configure;
			return Self;
		}

		public GraphExploreRequestDescriptor<TDocument> Vertices(params Action<VertexDefinitionDescriptor<TDocument>>[] configure)
		{
			VerticesValue = null;
			VerticesDescriptor = null;
			VerticesDescriptorAction = null;
			VerticesDescriptorActions = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (ConnectionsDescriptor is not null)
			{
				writer.WritePropertyName("connections");
				JsonSerializer.Serialize(writer, ConnectionsDescriptor, options);
			}
			else if (ConnectionsDescriptorAction is not null)
			{
				writer.WritePropertyName("connections");
				JsonSerializer.Serialize(writer, new HopDescriptor<TDocument>(ConnectionsDescriptorAction), options);
			}
			else if (ConnectionsValue is not null)
			{
				writer.WritePropertyName("connections");
				JsonSerializer.Serialize(writer, ConnectionsValue, options);
			}

			if (ControlsDescriptor is not null)
			{
				writer.WritePropertyName("controls");
				JsonSerializer.Serialize(writer, ControlsDescriptor, options);
			}
			else if (ControlsDescriptorAction is not null)
			{
				writer.WritePropertyName("controls");
				JsonSerializer.Serialize(writer, new ExploreControlsDescriptor<TDocument>(ControlsDescriptorAction), options);
			}
			else if (ControlsValue is not null)
			{
				writer.WritePropertyName("controls");
				JsonSerializer.Serialize(writer, ControlsValue, options);
			}

			if (QueryDescriptor is not null)
			{
				writer.WritePropertyName("query");
				JsonSerializer.Serialize(writer, QueryDescriptor, options);
			}
			else if (QueryDescriptorAction is not null)
			{
				writer.WritePropertyName("query");
				JsonSerializer.Serialize(writer, new QueryDsl.QueryContainerDescriptor<TDocument>(QueryDescriptorAction), options);
			}
			else if (QueryValue is not null)
			{
				writer.WritePropertyName("query");
				JsonSerializer.Serialize(writer, QueryValue, options);
			}

			if (VerticesDescriptor is not null)
			{
				writer.WritePropertyName("vertices");
				writer.WriteStartArray();
				JsonSerializer.Serialize(writer, VerticesDescriptor, options);
				writer.WriteEndArray();
			}
			else if (VerticesDescriptorAction is not null)
			{
				writer.WritePropertyName("vertices");
				writer.WriteStartArray();
				JsonSerializer.Serialize(writer, new VertexDefinitionDescriptor<TDocument>(VerticesDescriptorAction), options);
				writer.WriteEndArray();
			}
			else if (VerticesDescriptorActions is not null)
			{
				writer.WritePropertyName("vertices");
				writer.WriteStartArray();
				foreach (var action in VerticesDescriptorActions)
				{
					JsonSerializer.Serialize(writer, new VertexDefinitionDescriptor<TDocument>(action), options);
				}

				writer.WriteEndArray();
			}
			else if (VerticesValue is not null)
			{
				writer.WritePropertyName("vertices");
				JsonSerializer.Serialize(writer, VerticesValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class GraphExploreRequestDescriptor : RequestDescriptorBase<GraphExploreRequestDescriptor, GraphExploreRequestParameters>
	{
		internal GraphExploreRequestDescriptor(Action<GraphExploreRequestDescriptor> configure) => configure.Invoke(this);
		public GraphExploreRequestDescriptor(Elastic.Clients.Elasticsearch.Indices indices) : base(r => r.Required("index", indices))
		{
		}

		internal GraphExploreRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.GraphExplore;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public GraphExploreRequestDescriptor Routing(Elastic.Clients.Elasticsearch.Routing? routing) => Qs("routing", routing);
		public GraphExploreRequestDescriptor Timeout(Elastic.Clients.Elasticsearch.Duration? timeout) => Qs("timeout", timeout);
		public GraphExploreRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices indices)
		{
			RouteValues.Required("index", indices);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.Graph.Hop? ConnectionsValue { get; set; }

		private HopDescriptor ConnectionsDescriptor { get; set; }

		private Action<HopDescriptor> ConnectionsDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Graph.ExploreControls? ControlsValue { get; set; }

		private ExploreControlsDescriptor ControlsDescriptor { get; set; }

		private Action<ExploreControlsDescriptor> ControlsDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? QueryValue { get; set; }

		private QueryDsl.QueryContainerDescriptor QueryDescriptor { get; set; }

		private Action<QueryDsl.QueryContainerDescriptor> QueryDescriptorAction { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexDefinition>? VerticesValue { get; set; }

		private VertexDefinitionDescriptor VerticesDescriptor { get; set; }

		private Action<VertexDefinitionDescriptor> VerticesDescriptorAction { get; set; }

		private Action<VertexDefinitionDescriptor>[] VerticesDescriptorActions { get; set; }

		public GraphExploreRequestDescriptor Connections(Elastic.Clients.Elasticsearch.Graph.Hop? connections)
		{
			ConnectionsDescriptor = null;
			ConnectionsDescriptorAction = null;
			ConnectionsValue = connections;
			return Self;
		}

		public GraphExploreRequestDescriptor Connections(HopDescriptor descriptor)
		{
			ConnectionsValue = null;
			ConnectionsDescriptorAction = null;
			ConnectionsDescriptor = descriptor;
			return Self;
		}

		public GraphExploreRequestDescriptor Connections(Action<HopDescriptor> configure)
		{
			ConnectionsValue = null;
			ConnectionsDescriptor = null;
			ConnectionsDescriptorAction = configure;
			return Self;
		}

		public GraphExploreRequestDescriptor Controls(Elastic.Clients.Elasticsearch.Graph.ExploreControls? controls)
		{
			ControlsDescriptor = null;
			ControlsDescriptorAction = null;
			ControlsValue = controls;
			return Self;
		}

		public GraphExploreRequestDescriptor Controls(ExploreControlsDescriptor descriptor)
		{
			ControlsValue = null;
			ControlsDescriptorAction = null;
			ControlsDescriptor = descriptor;
			return Self;
		}

		public GraphExploreRequestDescriptor Controls(Action<ExploreControlsDescriptor> configure)
		{
			ControlsValue = null;
			ControlsDescriptor = null;
			ControlsDescriptorAction = configure;
			return Self;
		}

		public GraphExploreRequestDescriptor Query(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? query)
		{
			QueryDescriptor = null;
			QueryDescriptorAction = null;
			QueryValue = query;
			return Self;
		}

		public GraphExploreRequestDescriptor Query(QueryDsl.QueryContainerDescriptor descriptor)
		{
			QueryValue = null;
			QueryDescriptorAction = null;
			QueryDescriptor = descriptor;
			return Self;
		}

		public GraphExploreRequestDescriptor Query(Action<QueryDsl.QueryContainerDescriptor> configure)
		{
			QueryValue = null;
			QueryDescriptor = null;
			QueryDescriptorAction = configure;
			return Self;
		}

		public GraphExploreRequestDescriptor Vertices(IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexDefinition>? vertices)
		{
			VerticesDescriptor = null;
			VerticesDescriptorAction = null;
			VerticesDescriptorActions = null;
			VerticesValue = vertices;
			return Self;
		}

		public GraphExploreRequestDescriptor Vertices(VertexDefinitionDescriptor descriptor)
		{
			VerticesValue = null;
			VerticesDescriptorAction = null;
			VerticesDescriptorActions = null;
			VerticesDescriptor = descriptor;
			return Self;
		}

		public GraphExploreRequestDescriptor Vertices(Action<VertexDefinitionDescriptor> configure)
		{
			VerticesValue = null;
			VerticesDescriptor = null;
			VerticesDescriptorActions = null;
			VerticesDescriptorAction = configure;
			return Self;
		}

		public GraphExploreRequestDescriptor Vertices(params Action<VertexDefinitionDescriptor>[] configure)
		{
			VerticesValue = null;
			VerticesDescriptor = null;
			VerticesDescriptorAction = null;
			VerticesDescriptorActions = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (ConnectionsDescriptor is not null)
			{
				writer.WritePropertyName("connections");
				JsonSerializer.Serialize(writer, ConnectionsDescriptor, options);
			}
			else if (ConnectionsDescriptorAction is not null)
			{
				writer.WritePropertyName("connections");
				JsonSerializer.Serialize(writer, new HopDescriptor(ConnectionsDescriptorAction), options);
			}
			else if (ConnectionsValue is not null)
			{
				writer.WritePropertyName("connections");
				JsonSerializer.Serialize(writer, ConnectionsValue, options);
			}

			if (ControlsDescriptor is not null)
			{
				writer.WritePropertyName("controls");
				JsonSerializer.Serialize(writer, ControlsDescriptor, options);
			}
			else if (ControlsDescriptorAction is not null)
			{
				writer.WritePropertyName("controls");
				JsonSerializer.Serialize(writer, new ExploreControlsDescriptor(ControlsDescriptorAction), options);
			}
			else if (ControlsValue is not null)
			{
				writer.WritePropertyName("controls");
				JsonSerializer.Serialize(writer, ControlsValue, options);
			}

			if (QueryDescriptor is not null)
			{
				writer.WritePropertyName("query");
				JsonSerializer.Serialize(writer, QueryDescriptor, options);
			}
			else if (QueryDescriptorAction is not null)
			{
				writer.WritePropertyName("query");
				JsonSerializer.Serialize(writer, new QueryDsl.QueryContainerDescriptor(QueryDescriptorAction), options);
			}
			else if (QueryValue is not null)
			{
				writer.WritePropertyName("query");
				JsonSerializer.Serialize(writer, QueryValue, options);
			}

			if (VerticesDescriptor is not null)
			{
				writer.WritePropertyName("vertices");
				writer.WriteStartArray();
				JsonSerializer.Serialize(writer, VerticesDescriptor, options);
				writer.WriteEndArray();
			}
			else if (VerticesDescriptorAction is not null)
			{
				writer.WritePropertyName("vertices");
				writer.WriteStartArray();
				JsonSerializer.Serialize(writer, new VertexDefinitionDescriptor(VerticesDescriptorAction), options);
				writer.WriteEndArray();
			}
			else if (VerticesDescriptorActions is not null)
			{
				writer.WritePropertyName("vertices");
				writer.WriteStartArray();
				foreach (var action in VerticesDescriptorActions)
				{
					JsonSerializer.Serialize(writer, new VertexDefinitionDescriptor(action), options);
				}

				writer.WriteEndArray();
			}
			else if (VerticesValue is not null)
			{
				writer.WritePropertyName("vertices");
				JsonSerializer.Serialize(writer, VerticesValue, options);
			}

			writer.WriteEndObject();
		}
	}
}